<template>
    
    
    <el-card class="!border-none" shadow="never">
       
       
        <div class=" flex flex-1 flex-row">
            <el-form ref="formRef" class="-mb-4 " :model="queryParams" inline>
                
                <el-form-item label="用户信息">
                    <el-input
                        class="w-64"
                        v-model="queryParams.keyword"
                        placeholder="用户编号/昵称/手机号码"
                        clearable
                        @keyup.enter="resetOnePage"
                    />
                </el-form-item>
                
                
                <el-form-item label="注册时间">
                    <date-picker
                        v-model:startTime="queryParams.startTime"
                        v-model:endTime="queryParams.endTime"
                    />
                </el-form-item>
                
                <el-form-item label="注册来源">
                    <el-select class="w-64" v-model="queryParams.channel">
                        <el-option
                            v-for="(item, key) in ClientMap"
                            :key="key"
                            :label="item"
                            :value="key"
                        />
                    </el-select>
                </el-form-item>
            </el-form>
    
    
            <div class="flex-1  flex flex-row-reverse">
                <el-button class="mx-2" type="primary" @click="getPageLists">查询</el-button>
                <el-button class="mx-2" @click="resetParams">重置</el-button>
            </div>
        </div>
    
    </el-card>
    
    
    <el-card class="!border-none mt-4" shadow="never">
        <el-table size="large" v-loading="pagerData.loading" :data="pagerData.lists">
            
            <el-table-column label="用户编号" prop="sn" min-width="120"/>
            <el-table-column label="头像" min-width="100">
                <template #default="{ row }">
                    <el-avatar :src="row.avatar" :size="50"/>
                </template>
            </el-table-column>
            <el-table-column label="昵称" prop="nickname" min-width="100"/>
            <el-table-column label="账号" prop="username" min-width="120"/>
            <el-table-column label="手机号码" prop="mobile" min-width="100"/>
            <el-table-column label="性别" prop="sex" min-width="100"/>
            <el-table-column label="注册来源" prop="channel" min-width="100"/>
            <el-table-column label="注册时间" prop="createTime" min-width="120"/>
            <el-table-column label="操作" width="120" fixed="right">
                <template #default="{ row }">
                    <el-button v-perms="['user:detail']" type="primary" link>
                        <router-link
                            :to="{
                                    path: RouterManager.getRoutePath('user:detail'),
                                    query: {
                                        id: row.id
                                    }
                                }"
                        >
                            详情
                        </router-link>
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        
        
        <div class="flex justify-end mt-4">
            <pagination v-model="pagerData" @change="getPageLists"/>
        </div>
    
    
    </el-card>
</template>

<script lang='ts' setup>

import {usePagerManager} from "@/manager/base/PagerManager";
import {ClientMap} from "@/config/enums/appEnums";
import RouterManager from "@/manager/base/RouterManager";
import {getUserList} from "@/api/system/SystemUsersController";



/**
 * 查询数据
 */
const queryParams = reactive({
    keyword: '',
    channel: '',
    startTime: '',
    endTime: ''
})


/**
 * 获取用户分页
 */
const {pagerData, getPageLists, resetParams, resetOnePage} = usePagerManager({
    fetchFun: getUserList,
    params: queryParams
})


onMounted(() => {
    getPageLists()
})
</script>

